package com.changgou.page.listener;

import com.changgou.page.config.RabbitMQConfig;
import com.changgou.page.service.PageService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

//声明为ioc容器中的一个bean
@Component
public class PageListener {
    @Autowired
    private PageService pageService;

    @RabbitListener(queues = RabbitMQConfig.PAGE_CREATE_QUEUE)
    public void receiveMessage(String spuId) {
        //监听消息队列,在用户修改商品上架后，is_marketable会0->1，消息队列会接收一条spuId
        System.out.println("获取静态化页面id,id的值为:"+spuId);

        //调用方法,根据spuId生成静态页面
        pageService.generateHtml(spuId);
    }
}
